package il.ac.braude.sona.gui.menu;

import il.ac.braude.sona.constants.Resources;
import il.ac.braude.sona.gui.ButtonPanel;
import il.ac.braude.sona.gui.SONAFrame;
import il.ac.braude.sona.gui.forms.ImagePanel;

import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.event.ActionListener;

import javax.swing.AbstractButton;
import javax.swing.Box;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;

/**
 * Class contains all methods to create the GUI menu frame
 * sets all GUI basics for the menu 
 * @author  Ofek Ron
 * @author Avihay Avitan
 * @author Nitzan Inbar
 * @author Sasha Rozenthal
 * Laboratory in Software Engineering,Ort Braude College.</p>
 */
@SuppressWarnings("serial")
public class MenuFrame extends SONAFrame {
	/**
	 * button panel to be used with the menu buttons
	 */
	private ButtonPanel myButtonPanel;
	private JPanel mePanel=new JPanel();
/**
 * sets all basic GUI settings for the menu frame
 * initialize the button panel for later use
 */
	public MenuFrame() {
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		mePanel.setLayout(new BorderLayout());
		ImagePanel imagePanel = new ImagePanel();
		imagePanel.setBackground(Resources.Images.Background,true);
		JPanel somePanel = new JPanel();
		somePanel.add(imagePanel);
		mePanel.add(somePanel,BorderLayout.NORTH);
		JPanel centerTitle=new JPanel();
		JLabel label=new JLabel("<html><u>"+Resources.Strings.LoginTitle+"</u></html>");;
		label.setFont(Resources.Futura20);
		centerTitle.add(Box.createHorizontalGlue());
		centerTitle.add(label);
		centerTitle.add(Box.createHorizontalGlue());
		JPanel someOtherPanel = new JPanel();
		someOtherPanel.setLayout(new BorderLayout());
		someOtherPanel.add(centerTitle,BorderLayout.NORTH);
		myButtonPanel = new ButtonPanel();
		mePanel.add(someOtherPanel,BorderLayout.CENTER);
		someOtherPanel.add(myButtonPanel,BorderLayout.CENTER);
		super.add(mePanel);
		//setMinimumSize(new Dimension(450, 290));
		//setResizable(false);
	}

	/**
	 * adds a button to the frame,sets the action listener for the button
	 * @param title - button name
	 * @param listener - action listener for the button
	 */
	public void addButton(String title,ActionListener listener) {
		myButtonPanel.addButton(title, listener);
	}
	/**
	 * adds a button to the frame,sets the action listener for the button
	 * @param button - button type
	 * @param listener - action listener for the button
	 */
	public void addButton(AbstractButton button,ActionListener listener) {
		myButtonPanel.addButton(button, listener);
	}
	@Override
	public Component add(Component comp) {
		return myButtonPanel.add(comp);
	}
}
